<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::Config - openssl: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><span class="include">Enumerable</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-parse">::parse</a>
    <li ><a href="#method-c-parse_config">::parse_config</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-get_value">#get_value</a>
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-sections">#sections</a>
    <li ><a href="#method-i-to_s">#to_s</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::Config">
    <h1 id="class-OpenSSL::Config" class="class">
      class OpenSSL::Config
    </h1>

    <section class="description">
    
<p>Configuration for the openssl library.</p>

<p>Many system’s installation of openssl library will depend on your system configuration. See the value of <a href="Config.html#DEFAULT_CONFIG_FILE"><code>OpenSSL::Config::DEFAULT_CONFIG_FILE</code></a> for the location of the file for your host.</p>

<p>See also <a href="http://www.openssl.org/docs/apps/config.html">www.openssl.org/docs/apps/config.html</a></p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="DEFAULT_CONFIG_FILE">DEFAULT_CONFIG_FILE
          <dd><p>The default system configuration file for <a href="../OpenSSL.html"><code>OpenSSL</code></a>.</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(filename) &rarr; OpenSSL::Config
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an instance of <a href="Config.html"><code>OpenSSL::Config</code></a> from the content of the file specified by <em>filename</em>.</p>

<p>This can be used in contexts like <a href="X509/ExtensionFactory.html#attribute-i-config"><code>OpenSSL::X509::ExtensionFactory.config=</code></a></p>

<p>This can raise <a href="../IO.html"><code>IO</code></a> exceptions based on the access, or availability of the file. A <a href="ConfigError.html"><code>ConfigError</code></a> exception may be raised depending on the validity of the data being configured.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
config_initialize(int argc, VALUE *argv, VALUE self)
{
    CONF *conf = GetConfig(self);
    VALUE filename;

    /* 0-arguments call has no use-case, but is kept for compatibility */
    rb_scan_args(argc, argv, &quot;01&quot;, &amp;filename);
    rb_check_frozen(self);
    if (!NIL_P(filename)) {
        BIO *bio = BIO_new_file(StringValueCStr(filename), &quot;rb&quot;);
        if (!bio)
            ossl_raise(eConfigError, &quot;BIO_new_file&quot;);
        config_load_bio(conf, bio); /* Consumes BIO */
    }
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          parse(string) &rarr; OpenSSL::Config
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses a given <em>string</em> as a blob that contains configuration for <a href="../OpenSSL.html"><code>OpenSSL</code></a>.</p>

                              <div class="method-source-code" id="parse-source">
            <pre>static VALUE
config_s_parse(VALUE klass, VALUE str)
{
    VALUE obj = config_s_alloc(klass);
    CONF *conf = GetConfig(obj);
    BIO *bio;

    bio = ossl_obj2bio(&amp;str);
    config_load_bio(conf, bio); /* Consumes BIO */
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse_config" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          parse_config(io) &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses the configuration data read from <em>io</em> and returns the whole content as a Hash.</p>

                              <div class="method-source-code" id="parse_config-source">
            <pre>static VALUE
config_s_parse_config(VALUE klass, VALUE io)
{
    VALUE obj, sections, ret;
    long i;

    obj = config_s_parse(klass, io);
    sections = config_get_sections(obj);
    ret = rb_hash_new();
    for (i = 0; i &lt; RARRAY_LEN(sections); i++) {
        VALUE section = rb_ary_entry(sections, i);
        rb_hash_aset(ret, section, config_get_section(obj, section));
    }
    return ret;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          config[section] &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gets all key-value pairs in a specific <em>section</em> from the current configuration.</p>

<p>Given the following configurating file being loaded:</p>

<pre class="ruby"><span class="ruby-identifier">config</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">load</span>(<span class="ruby-string">&#39;foo.cnf&#39;</span>)
  <span class="ruby-comment">#=&gt; #&lt;OpenSSL::Config sections=[&quot;default&quot;]&gt;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-comment">#=&gt; [ default ]</span>
  <span class="ruby-comment">#   foo=bar</span>
</pre>

<p>You can get a hash of the specific section like so:</p>

<pre class="ruby"><span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;default&#39;</span>]
  <span class="ruby-comment">#=&gt; {&quot;foo&quot;=&gt;&quot;bar&quot;}</span>
</pre>

                              <div class="method-source-code" id="5B-5D-source">
            <pre>static VALUE
config_get_section(VALUE self, VALUE section)
{
    CONF *conf = GetConfig(self);
    STACK_OF(CONF_VALUE) *sk;
    int i, entries;
    VALUE hash;

    hash = rb_hash_new();
    StringValueCStr(section);
    if (!(sk = NCONF_get_section(conf, RSTRING_PTR(section)))) {
        ossl_clear_error();
        return hash;
    }
    entries = sk_CONF_VALUE_num(sk);
    for (i = 0; i &lt; entries; i++) {
        CONF_VALUE *entry = sk_CONF_VALUE_value(sk, i);
        rb_hash_aset(hash, rb_str_new_cstr(entry-&gt;name),
                     rb_str_new_cstr(entry-&gt;value));
    }
    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each { |section, key, value| }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Retrieves the section and its pairs for the current configuration.</p>

<pre class="ruby"><span class="ruby-identifier">config</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">section</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
  <span class="ruby-comment"># ...</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="each-source">
            <pre>static VALUE
config_each(VALUE self)
{
    CONF *conf = GetConfig(self);

    RETURN_ENUMERATOR(self, 0, 0);

    lh_doall_arg((_LHASH *)conf-&gt;data, LHASH_DOALL_ARG_FN(each_conf_value),
                 NULL);
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_value" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          get_value(section, key) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gets the value of <em>key</em> from the given <em>section</em>.</p>

<p>Given the following configurating file being loaded:</p>

<pre class="ruby"><span class="ruby-identifier">config</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">load</span>(<span class="ruby-string">&#39;foo.cnf&#39;</span>)
  <span class="ruby-comment">#=&gt; #&lt;OpenSSL::Config sections=[&quot;default&quot;]&gt;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-comment">#=&gt; [ default ]</span>
  <span class="ruby-comment">#   foo=bar</span>
</pre>

<p>You can get a specific value from the config if you know the <em>section</em> and <em>key</em> like so:</p>

<pre class="ruby"><span class="ruby-identifier">config</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-string">&#39;default&#39;</span>,<span class="ruby-string">&#39;foo&#39;</span>)
  <span class="ruby-comment">#=&gt; &quot;bar&quot;</span>
</pre>

                              <div class="method-source-code" id="get_value-source">
            <pre>static VALUE
config_get_value(VALUE self, VALUE section, VALUE key)
{
    CONF *conf = GetConfig(self);
    const char *str, *sectionp;

    StringValueCStr(section);
    StringValueCStr(key);
    /* For compatibility; NULL means &quot;default&quot;. */
    sectionp = RSTRING_LEN(section) ? RSTRING_PTR(section) : NULL;
    str = NCONF_get_string(conf, sectionp, RSTRING_PTR(key));
    if (!str) {
        ossl_clear_error();
        return Qnil;
    }
    return rb_str_new_cstr(str);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-initialize_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize_copy</span><span
                                class="method-args">(p1)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE
config_initialize_copy(VALUE self, VALUE other)
{
    CONF *conf = GetConfig(self);
    VALUE str;
    BIO *bio;

    str = rb_funcall(other, rb_intern(&quot;to_s&quot;), 0);
    rb_check_frozen(self);
    bio = ossl_obj2bio(&amp;str);
    config_load_bio(conf, bio); /* Consumes BIO */
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          inspect &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>String representation of this configuration object, including the class name and its sections.</p>

                              <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
config_inspect(VALUE self)
{
    VALUE str, ary = config_get_sections(self);
    const char *cname = rb_class2name(rb_obj_class(self));

    str = rb_str_new_cstr(&quot;#&lt;&quot;);
    rb_str_cat_cstr(str, cname);
    rb_str_cat_cstr(str, &quot; sections=&quot;);
    rb_str_append(str, rb_inspect(ary));
    rb_str_cat_cstr(str, &quot;&gt;&quot;);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sections" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sections &rarr; array of string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get the names of all sections in the current configuration.</p>

                              <div class="method-source-code" id="sections-source">
            <pre>static VALUE
config_get_sections(VALUE self)
{
    CONF *conf = GetConfig(self);
    VALUE ary;

    ary = rb_ary_new();
    lh_doall_arg((_LHASH *)conf-&gt;data, LHASH_DOALL_ARG_FN(get_conf_section),
                 &amp;ary);
    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Gets the parsable form of the current configuration.</p>

<p>Given the following configuration being created:</p>

<pre class="ruby"><span class="ruby-identifier">config</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-comment">#=&gt; #&lt;OpenSSL::Config sections=[]&gt;</span>
<span class="ruby-identifier">config</span>[<span class="ruby-string">&#39;default&#39;</span>] = {<span class="ruby-string">&quot;foo&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-string">&quot;bar&quot;</span>,<span class="ruby-string">&quot;baz&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-string">&quot;buz&quot;</span>}
  <span class="ruby-comment">#=&gt; {&quot;foo&quot;=&gt;&quot;bar&quot;, &quot;baz&quot;=&gt;&quot;buz&quot;}</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-comment">#=&gt; [ default ]</span>
  <span class="ruby-comment">#   foo=bar</span>
  <span class="ruby-comment">#   baz=buz</span>
</pre>

<p>You can parse get the serialized configuration using <a href="Config.html#method-i-to_s"><code>to_s</code></a> and then parse it later:</p>

<pre class="ruby"><span class="ruby-identifier">serialized_config</span> = <span class="ruby-identifier">config</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-comment"># much later...</span>
<span class="ruby-identifier">new_config</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">serialized_config</span>)
  <span class="ruby-comment">#=&gt; #&lt;OpenSSL::Config sections=[&quot;default&quot;]&gt;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">new_config</span>
  <span class="ruby-comment">#=&gt; [ default ]</span>
      <span class="ruby-identifier">foo</span>=<span class="ruby-identifier">bar</span>
      <span class="ruby-identifier">baz</span>=<span class="ruby-identifier">buz</span>
</pre>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
config_to_s(VALUE self)
{
    CONF *conf = GetConfig(self);
    VALUE str;

    str = rb_str_new(NULL, 0);
    lh_doall_arg((_LHASH *)conf-&gt;data, LHASH_DOALL_ARG_FN(dump_conf_value),
                 &amp;str);
    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

